package migrations

import (
	"github.com/goravel/framework/contracts/database/schema"
	"github.com/goravel/framework/facades"
)

type M20250310032409CreateSourceDatabasesTable struct {
}

// Signature The unique signature for the migration.
func (r *M20250310032409CreateSourceDatabasesTable) Signature() string {
	return "20250310032409_create_source_databases_table"
}

// Up Run the migrations.
func (r *M20250310032409CreateSourceDatabasesTable) Up() error {
	if !facades.Schema().HasTable("source_databases") {
		return facades.Schema().Create("source_databases", func(table schema.Blueprint) {
			table.ID()
			table.UnsignedInteger("migration_task_id")
			table.Enum("type", []any{"Oracle", "Gaussdb(DWS)"}) // 类型（oracle|gaussdb(dws)）
			table.String("ip")
			table.String("port")
			table.String("username")
			table.String("password")
			table.String("schema")
			table.String("Service")
			table.Timestamps()
			
			table.Unique("ip", "port", "schema")
		})
	}

	return nil
}

// Down Reverse the migrations.
func (r *M20250310032409CreateSourceDatabasesTable) Down() error {
 	return facades.Schema().DropIfExists("source_databases")
}
